﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using FreeGoo.WpfRenderer;

namespace FreeGoo.Silverlight.Demo
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }

        private void UserControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            CrossMouse.MouseLeftButtonDown(e.GetPosition);
            ShowMouse();
        }

        private void UserControl_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            CrossMouse.MouseLeftButtonUp(e.GetPosition);
            ShowMouse();
        }

        private void UserControl_MouseMove(object sender, MouseEventArgs e)
        {
            CrossMouse.MouseMoved(e.GetPosition);
            ShowMouse();
        }

        private void ShowMouse()
        {
            Point point = CrossMouse.GetPosition(this);

            MousePositionLabel.Content =
                string.Format(
                    "({0}, {1}), IsLeftButtonDown={2}",
                    point.X,
                    point.Y,
                    CrossMouse.IsLeftButtonDown);
        }
    }
}
